<h1>Ordem de Serviço</h1>

<div class="add-link">
	<a href="<?=$this->url(array("module"=>"admin","controller"=>"os","action"=>"new"),null,true)?>">Nova O.S.</a>
</div>
<table width="90%" cellpadding="3" cellspacing="0" border="1">
   <tr>
      <td class="titulo">Data/Hora</td>
      <td class="titulo">Motorista</td>
      <td class="titulo">Veiculo</td>
      <td class="titulo">Status</td>
      <td class="titulo">Ações</td>
   </tr>
   <? foreach($this->dados AS $key => $os): ?>
   <tr>
      <td>
      	<?
      		$data = explode(" ",$os['data_os']);
      		$data_os = explode("-",$data[0]);
      		$hora_os = explode(":",$data[1]);
      		echo $data_os[2].'-'.$data_os[1].'-'.$data_os[0]." ".$hora_os[0].':'.$hora_os[1];
      	?>
      </td>
      <td>
      	<?php 
      		foreach($this->dados_m AS $key => $motorista):
      			if($os['id_motorista'] == $motorista['id_motorista'])
      				echo $motorista['nome'];	
      		endforeach;
      	?>      
      </td>
      <td>
      	<?php 
      		foreach($this->dados_v AS $key => $veiculo):
      			if($os['id_veiculo'] == $veiculo['id_veiculo'])
      				echo $veiculo['placa'];	
      		endforeach;
      	?> 
      </td>
      <td>
      <?php 
      	if($os['status'] == 1)
      		echo "Aberto";
      	else if($os['status'] == 2)	
      		echo "Em Movimento";
      	else if($os['status'] == 3)
      		echo "Fechado";	
      ?>
      </td>
      <td>
		<center>
			<a href="<?=$this->url(array("module"=>"admin","controller"=>"os","action"=>"show","id"=>"{$os['id_os']}"),null,true)?>">
         		<img src="imgs/icons/icon_preview.png" title="Visualizar" border="0" align="middle"/>
         	</a>
         	<a href="<?=$this->url(array("module"=>"admin","controller"=>"os","action"=>"edit","id"=>"{$os['id_os']}"),null,true)?>">
         		<img src="imgs/icons/icon_edit.png"  title="Editar" border="0" align="middle"/>
         	</a>
         	<a href="<?=$this->url(array("module"=>"admin","controller"=>"os","action"=>"destroy","id"=>"{$os['id_os']}"),null,true)?>">
         		<img src="imgs/icons/icon_delete.png"  title="Deletar" border="0" align="middle"/>
         	</a>
		</center>
      </td>
   </tr>
   <? endforeach; ?>
</table>